One-Click Example
Below is our one-click Wallet SDK example using the Fuel test faucet on Rinkeby.
Try it out!
// import fuel from "@fuel-js/wallet"
await import('https://unpkg.com/@fuel-js/wallet@latest/umd/fuel.umd.min.js');
// Create a new wallet with a new key
// Tip: try setting `null` to `web3.currentProvider` to run with MetaMask
const wallet = new fuel.Wallet(null, {
network: 'rinkeby',
});
// Get yourself some fake Moons
await wallet.faucet();
// Establish faucet token id
const faucetToken = fuel.constants.faucetToken;
// Get your fake moons balance
console.log('my balance: ',
await wallet.balance(faucetToken, { format: 'ether' }));
// Send yourself some faucet token
const tx = await wallet.transfer(faucetToken, wallet.address, '4.5', { units: 'ether' });
// Checkout your transaction on the Block Explorer
console.log('check out your tx: ' + window.rinkebyTx + tx.transactionId);
run